from base.base_page import BasePage
from page.mail_list_manager.org_page import OrgPageElements
from page import BasePageElements
import allure

class OrgPage(BasePage):

    def create_org(self, org_name):
        # 点击-通信录
        with allure.step("# 点击-通信录"):
            self.my_click(BasePageElements.mail_list_button, time_out=20)
        # 点击-设置按钮
        with allure.step("点击-设置"):
            self.my_click(OrgPageElements.set_button)
        # 点击-添加子部门
        with allure.step("点击-添加子部门"):
            self.my_click(OrgPageElements.add_child_org_button)
        # 输入部门名称
        if org_name:
            with allure.step("输入部门名称：{}".format(org_name)):
                self.my_send_keys(OrgPageElements.input_org_name, org_name)
        # 点击确定
        with allure.step("点击-确定"):
            self.my_click(BasePageElements.define_button)
        # 断言报错信息
        with allure.step("获取报错信息"):
            tip_info_text = self.my_get_text(BasePageElements.tip_info)
        return tip_info_text